package com.chatgpt.platformbasedchatgpt.controller;


import com.chatgpt.platformbasedchatgpt.dao.Question;
import com.chatgpt.platformbasedchatgpt.service.QuestionService;
import com.chatgpt.platformbasedchatgpt.utils.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Chat
 * @since 2023-12-21
 */
@RestController
public class QuestionController {
    @Autowired
    QuestionService questionService;

    @GetMapping("/getQuestion/{id}")
    public CommonResult getQuestion(@PathVariable int id){
        return CommonResult.success(questionService.getQuestion(id));
    }
    @PostMapping("/queryQuestion")
    public CommonResult queryQuestion(@RequestBody Question question){
        return CommonResult.success(questionService.queryQuestion(question));
    }
    @GetMapping("/getQuestionList/{userId}")
    public CommonResult getQuestionList(@PathVariable int userId){
        return CommonResult.success(questionService.getQuestionList(userId));
    }
    @PostMapping("/saveQuestion")
    public CommonResult saveQuestion(@RequestBody Question question){
        return CommonResult.success(questionService.insertQuestion(question));
    }
    @PostMapping("/modQuestion")
    public CommonResult modQuestion(@RequestBody Question question){
        return CommonResult.success(questionService.updateQuestion(question));
    }
    @GetMapping("/delQuestion/{id}")
    public CommonResult delQuestion(@PathVariable int id){
        return CommonResult.success(questionService.deleteQuestion(id));
    }

}

